﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace SDT.Mobile
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
                "UrlRewriteArticleIndex", // Route name
                "{clientName}_a/{id}", // URL with parameters
                new { controller = "article", action = "index", id = 0 }, // Parameter defaults
                new string[] { "SDT.Site.Controllers" } // Parameter defaults
            );
            routes.MapRoute(
                "UrlRewriteArticleList", // Route name
                "{clientName}_sa/{id}", // URL with parameters
                new { controller = "article", action = "list", id = 0 }, // Parameter defaults
                new string[] { "SDT.Site.Controllers" } // Parameter defaults
            );
            routes.MapRoute(
                "UrlRewriteArticleDetailList", // Route name
                "{clientName}/{title}-dta-{id}.html", // URL with parameters
                new { controller = "article", action = "details", id = 0 }, // Parameter defaults
                new string[] { "SDT.Site.Controllers" } // Parameter defaults
            );
            routes.MapRoute(
                "RewriteProduct",
                "{clientName}/p/{id}/{catid}/{cityid}/{distrid}/{areaid}/{priceid}/{projectid}/{timeid}",
                new { controller = "product", action = "index", id = 0, catid = 0, cityid = 0, distrid = 0, areaid = 0, priceid = 0, projectid = 0, timeid = 0, clientName = @"[\w-]+" }, // Parameter defaults
                new string[] { "SDT.Site.Controllers" } // Parameter defaults
            );
            routes.MapRoute(
                "RewriteProductDetails",
                "{clientName}/{title}-p-{id}.html",
                new { controller = "product", action = "details", id = 0, clientName = @"[\w-]+" }, // Parameter defaults
                new string[] { "SDT.Site.Controllers" } // Parameter defaults
            );
            routes.MapRoute(
                "RewriteProductList",
                "{clientName}/{title}/p/{id}",
                new { controller = "product", action = "list", id = 0, clientName = @"[\w-]+" }, // Parameter defaults
                new string[] { "SDT.Site.Controllers" } // Parameter defaults
            );
            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = 0 }, // Parameter defaults
                new string[] { "SDT.Site.Controllers" } // Parameter defaults
            );
            

        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
        }
    }
}